package com.zuipin.service;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

import com.zuipin.entity.RedPacket;
import com.zuipin.framework.exception.CustomException;
import com.zuipin.framework.result.PageResult;
import com.zuipin.framework.result.Result;
import com.zuipin.util.Pagination;
import com.zuipin.vo.RedPacketDetailVo;
import com.zuipin.vo.RedPacketShowVo;
import com.zuipin.vo.RedPacketVo;
import com.zuipin.vo.SearchCanUseVo;
import com.zuipin.vo.SendRedPacketResult;

/**
 * @ClassName: IRedPacketService
 * @author wuyicheng
 * @time 2017年3月27日下午3:48:30
 */
public interface IRedPacketService {
	
	public RedPacket findById(Long id);
	
	public void insert(RedPacket redPacket);
	
	public void update(RedPacket redPacket);
	
	/** 
	 *
	 * @Title: findListByPage 
	 * @author: wuyicheng
	 * @date: 2017年4月24日下午5:03:24 
	 * @param redPacket
	 * @param page
	 * @return
	 * @return: List<RedPacket>
	 * @throws 
	 */
	public List<RedPacket> findListByPage(RedPacket redPacket, Pagination page);
	
	/** 
	 *
	 * @Title: findList 
	 * @author: wuyicheng
	 * @date: 2017年4月25日上午12:38:10 
	 * @param redPacket
	 * @return
	 * @return: List<RedPacket>
	 * @throws 
	 */
	public List<RedPacket> findList(RedPacket redPacket);
	
	/** 
	 *	统计红包数量
	 *
	 * @Title: countRedPacket 
	 * @author: wuyicheng
	 * @date: 2017年4月27日下午6:26:09 
	 * @param memberId
	 * @param sysId
	 * @return
	 * @return: long
	 * @throws 
	 */
	public long countRedPacket(Long memberId, Long sysId);
	
	/**
	 * @throws CustomException 
	 * 根据优惠编码和密码激活红包
	 * 
	 * @throws ParseException   
	 * 
	 * @Title: doActivateByCodeAndPwd 
	 * @author: wuyicheng
	 * @date: 2017年5月3日上午9:32:36 
	 * @param memberId
	 * @param sysId
	 * @param activateCode
	 * @param activatePassword
	 * @return
	 * @return: Result<Map<String,Object>>
	 * @throws 
	 */
	public Result<Map<String, Object>> doActivateByCodeAndPwd(Long memberId, Long sysId, String activateCode, String activatePassword) throws ParseException, CustomException;
	
	/**
	 * @throws CustomException 
	 * @throws ParseException  
	 * 根据红包序列号激活红包
	 * 
	 * @Title: doActivateBySerialNumber 
	 * @author: wuyicheng
	 * @date: 2017年5月3日上午11:10:06 
	 * @param memberId
	 * @param sysId
	 * @param serialNumber
	 * @return
	 * @return: Result<Map<String,Object>>
	 * @throws 
	 */
	public Result<Map<String, Object>> doActivateBySerialNumber(Long memberId, Long sysId, String serialNumber) throws ParseException, CustomException;
	
	/**
	 * @throws CustomException 
	 * @throws ParseException  
	 *
	 * @Title: doActivateByRuleId 
	 * @author: wuyicheng
	 * @date: 2017年5月18日下午5:05:46 
	 * @param memberId
	 * @param sysId
	 * @param ruleId
	 * @return
	 * @return: Result<Map<String,Object>>
	 * @throws 
	 */
	public Result<Map<String, Object>> doActivateByRuleId(Long memberId, Long sysId, Long ruleId) throws ParseException, CustomException;
	
	/**
	 * 查询可用红包
	 *
	 * @Title: getCanUseRedpacket 
	 * @author: wuyicheng
	 * @date: 2017年6月21日上午11:21:22 
	 * @param searchCanUseVo
	 * @return
	 * @throws CustomException
	 * @return: List<RedPacketVo>
	 * @throws
	 */
	public List<RedPacketVo> getCanUseRedpacket(SearchCanUseVo searchCanUseVo) throws CustomException;
	
	/**
	 * @throws CustomException 
	 * @throws ParseException  
	 * 派发红包
	 *
	 * @Title: toSendRedPacket 
	 * @author: wuyicheng
	 * @date: 2017年7月10日上午11:53:08 
	 * @param sysUserId
	 * @param sysId
	 * @param ruleSetId
	 * @param isMemberLevel
	 * @param acceptor
	 * @return
	 * @return: Result<SendRedPacketResult>
	 * @throws 
	 */
	public Result<SendRedPacketResult> toSendRedPacket(Long sysUserId, Long sysId, Long ruleSetId, Short isMemberLevel, String acceptor) throws ParseException, CustomException;
	
	/** 
	 * 统计红包数量
	 * 
	 * @Title: countRedPacket 
	 * @author: wuyicheng
	 * @date: 2017年7月11日下午2:23:56 
	 * @param redPacket
	 * @return
	 * @return: long
	 * @throws 
	 */
	public long countRedPacket(RedPacket redPacket);
	
	public void insertBatch(String[] list, RedPacket red);
	
	public void modityStatusByRuleId(Long ruleId, Long sysId, String status);
	
	public PageResult<List<RedPacketDetailVo>> findRedPacketListPage(Long sysId, Integer pageSize, Integer pageNumber, String status, String phoneOrEmail, Long id, String orderNo,
			Long ruleId);
	
	public RedPacketDetailVo findRedPacketDetailById(Long id, Long sysId);
	
	/** 
	 * 导出红包序列号
	 * 
	 * @Title: toExportSerialNumber 
	 * @author: wuyicheng
	 * @date: 2017年7月12日上午11:35:13 
	 * @param ruleSetIds
	 * @param sysId
	 * @param result
	 * @return
	 * @return: Result<List<Map<String,Object>>>
	 * @throws 
	 */
	public Result<List<Map<String, Object>>> toExportSerialNumber(String ruleSetIds, Long sysId, Result<List<Map<String, Object>>> result);
	
	/**
	 * 批量更新操作
	 *
	 * @Title: batchUpdate 
	 * @author: wuyicheng
	 * @date: 2017年7月12日下午5:52:09 
	 * @param redPackets
	 * @return: void
	 * @throws
	 */
	public void batchUpdate(List<RedPacket> redPackets);
	
	public Boolean sendRedPacket(List<Long> ruleIds, Long sysId, Integer num, Long memberId, Long sysUserId, Long winnRecordId, String type, Long orderId)
			throws ParseException, CustomException;
	
	public PageResult<List<RedPacketShowVo>> searchRedPacketByStatus(Long memberId, Long sysId, String status, Pagination page);
	
	/*	public PageResult<List<RedPacketShowVo>> searchUnusedRedPacket(Long memberId, Long sysId, Pagination page);
		
		public PageResult<List<RedPacketShowVo>> searchExpiredRedPacket(Long memberId, Long sysId, Pagination page);*/
	public void updateOrderSend(Long sendOrderId, Long memberId);
	
	public List<RedPacket> selectOrderSend(Long sendOrderId, Long memberId);
}
